package com.vma.jifu.others.impl;

import com.jfinal.plugin.activerecord.Page;
import com.vma.jifu.bizModel.model.Areas;
import com.vma.jifu.bizModel.model.Cities;
import com.vma.jifu.bizModel.model.Provinces;
import com.vma.jifu.others.CommonService;


import java.util.List;

/**
 * Created by kitabi on 2017/6/23.
 */
public class CommonServiceImpl implements CommonService {


    public List<Provinces> qryProvinces(String name) {
        String temp="";
        if(name != null && !"".equals(name)){
            temp="and Province like %"+name+"%";
        }

        List<Provinces> provincesPage = Provinces.dao.find("select * from provinces  " );
        return provincesPage;

    }

    public List<Cities> qryCities(String name, int province) {
        String temp="";
        if(name != null && !"".equals(name)){
            temp="and city like %"+name+"%";
        }

        List<Cities> provincesPage = Cities.dao.find("select * from cities where 1=1 "+temp +" and provinceid= "+province );
        return provincesPage;
    }

    public List<Areas> qryAreas(String name, int city) {
        String temp="";
        if(name != null && !"".equals(name)){
            temp="and area like %"+name+"%";
        }

        List<Areas> provincesPage = Areas.dao.find("select * from areas where 1=1 "+temp +" and cityid= "+city );
        return provincesPage;
    }
}
